from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

import sys

sys.path.append(r'..')
from web_base.base_page import BasePage
from page_object.login_page import LoginPage

class PerinforPage(BasePage):
    url = r'/bsams/front/asset_user/user_info.do'

    # 电话定位
    phone_btn_loc = (By.ID, 'phone')
    phone_ok_loc = (By.LINK_TEXT, '保存')

    # 密码定位
    pwd_btn_loc = (By.LINK_TEXT, '修改密码')
    pwd_old_loc = (By.ID, 'oldPassword')
    pwd_new_loc = (By.ID, 'newPassword1')
    pwd_sure_loc = (By.ID, 'newPassword2')
    pwd_ok_loc = (By.XPATH, '//*[@id="cboxLoadedContent"]/div/div/div[2]/div[4]/div[1]')

    # 修改电话
    def perinfor_phone(self,phone):
        self.open()
        self.input_ele(self.phone_btn_loc, phone)
        self.ele_click(self.phone_ok_loc)
        sleep(3)
        text = self.get_alert_text()
        self.alert_click()
        return text

    # 修改密码
    def perinfor_pwd(self,oldpwd,newpwd1,newpwd2):
        self.open()
        self.ele_click(self.pwd_btn_loc)
        self.input_ele(self.pwd_old_loc, oldpwd)
        self.input_ele(self.pwd_new_loc, newpwd1)
        self.input_ele(self.pwd_sure_loc, newpwd2)
        self.ele_click(self.pwd_ok_loc)
        sleep(3)
        text = self.get_alert_text()
        self.alert_click()
        return text


if __name__ == '__main__':
    pass
